import axois from 'axios';
const mutations = {
	first_init(state,obj){
				if(localStorage.getItem(obj.url)){
					state.newList=JSON.parse(localStorage.getItem(obj.url))
				}else{
					axois({
					methods:'get',
					url:obj.url,
					params:{
						rid:state.count
					}
					
				}).then((res)=>{
					state.newList = res.data.data;
//					console.log(state.newList)
					localStorage.setItem(obj.url,JSON.stringify(res.data.data))
				})	
					}
	},
	_init(state,obj){
		axois({
					method:'get',
					url:obj.url,
					params:{
						rid:obj.n
					}
				}).then((res)=>{
//					console.log(res)
					state.contentList = res.data.data
					const listNum = state.contentList.length;
					let con = state.contentList.splice(0,listNum)
					state.newList = state.newList.concat(con)
				})
				
	},
	add(state){
		state.count++
	},
	recover(state){
		state.count = 1
//		console.log(1)
	}
}

export default mutations;